<?php 

function dateValid($date=null)
{
	//buat array nama hari dalam bahasa Indonesia dengan urutan 1-7
	$array_hari = array(1=>'Senin','Selasa','Rabu','Kamis','Jumat', 'Sabtu','Minggu');
	//buat array nama bulan dalam bahasa Indonesia dengan urutan 1-12
	$array_bulan = array(1=>'Januari','Februari','Maret', 'April', 'Mei', 'Juni','Juli','Agustus',
					'September','Oktober', 'November','Desember');
	
	if ($date == '0000-00-00' || $date == '1970-01-01' || $date == null ){
		return "";
	} else {
		//jika $date diisi, makan tanggal yang diformat adalah tanggal tersebut
		$date  = strtotime($date);
		$hari  = $array_hari[date('N',$date)];
		$tanggal = date ('j', $date);
		$bulan = $array_bulan[date('n',$date)];
		$tahun = date('Y',$date);
		$formatTanggal = $tanggal ." ". $bulan ;
		return $formatTanggal;
	}
}if(@$type!=="excel") { ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Laporan Hasil Tender</title>
<?php echo css_asset("printstyle.css"); ?>
</head>
<body>
<?php } else { ?>
<html xmlns:o="urn:schemas-microsoft-com:office:office"
                                       xmlns:x="urn:schemas-microsoft-com:office:excel"
                                        xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Laporan Hasil Tender</title>
<style>
.table{
        border-collapse:collapse;      
}
</style>
<xml>
 <x:ExcelWorkbook>
  <x:ExcelWorksheets>
   <x:ExcelWorksheet>
    <x:Name>Sheet</x:Name>
    <x:WorksheetOptions>
     <x:Print>
        <x:Gridlines />
     </x:Print>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
  </x:ExcelWorksheets>
 </x:ExcelWorkbook>
</xml>
</head>
<body>
<?php } 
if (count($data_print) > 0 ) {
?>
<p></p>
	<small>PT PP (Persero) Tbk.<br>
	DVO 3 - TEKNIK - CABANG <?php echo latinToRomawi(str_replace("CABANG ","",$data_print[0]->cabang_nama)); ?><br>
	&nbsp;
	</small>
	<h3><center>MASTER LIST<br /><small>DOKUMEN TENDER (PP-PEMENANG AND ON GOING FILLING) TAHUN <?php echo $tahun; ?></small></center></h3>
<table summary='Laporan Hasil Tender' width="100%" class="print">
	<thead>
		<tr>
			<th scope='col' rowspan=2>No</th>
			<th scope='col' rowspan=2>No Dokumen</th>
			<th scope='col' rowspan=2>Nama Proyek</th>
			<th scope='col' rowspan=2>Bulan</th>
			<th scope='col' rowspan=2>CB</th>
			<th scope='col' rowspan=2>Pemilik</th>
			<th scope='col' rowspan=2>Nilai</th>
			<th scope='col' rowspan=2>Lokasi</th>
			<th scope='col' colspan=4>Keterangan</th>
		</tr>
		<tr>
			<th scope='col' >RKS</th>
			<th scope='col' >BoQ</th>
			<th scope='col' >GBR</th>
			<th scope='col' >Lokasi</th>
		</tr>
	</thead>
	<tbody>
	<?php $i=0; $jadwal_id = 0; foreach($data_print as $print) {
	
	if ($jadwal_id != $print->jadwal_id){ $i++;
	?>
	<tr ><td><?php echo $i ; ?></td>
	<td><?php echo $print->jadwal_nodoc  ; ?></td>
	<td><?php echo $print->jadwal_namaproyek  ; ?></td>
	<td><?php echo dateValid($print->jadwal_tglpemasukan) ; ?></td>
	<td>&nbsp;</td>
	<td><?php echo $print->owner_nama  ; ?></td>
	<td style="text-align:right"><?php echo number_format($print->jadwal_nk,0,",","."); ?></td>
	<td><?php echo $print->jadwal_lokasi  ; ?></td>
	<td><?php if ( $print->jadwal_flagboq == "Y") echo "V"; else echo "-"; ?></td>
	<td><?php if ( $print->jadwal_flaqrks == "Y") echo "V"; else echo "-"; ?></td>
	<td><?php if ( $print->jadwal_flaggbr == "Y") echo "V"; else echo "-"; ?></td>
	<td>&nbsp;</td></tr>
	<?php 
	}
	if ($print->t_revisi_id != ""){?>

	<tr><td>&nbsp;</td>
	<td><?php echo $print->revisi_keterangan  ; ?></td>
	<td><?php echo dateValid($print->revisi_tgl) ; ?></td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td style="text-align:right"><?php echo number_format($print->revisi_harga,0,",","."); ?></td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td></tr>
	
	<?php  } ?>
	<?php  
		$jadwal_id = $print->jadwal_id;
	} ?>
	</tbody>
	</table>	<?php  }else{ ?>
		<center><b>Tidak ada data yang ditemukan!</b></center>
		<?php } ?>
</body>
</html>